package com.firefly.web.controller.admin.cms;

import com.firefly.dao.dto.cms.AdPosDto;
import com.firefly.dao.dto.cms.AdPosSearchDto;
import com.firefly.web.controller.admin.ConsoleApiRestController;
import com.firefly.dao.dto.CommonDto;
import com.firefly.dao.vo.CommonListVo;
import com.firefly.dao.vo.cms.AdPosVo;
import com.firefly.service.command.cms.AdPosCommand;
import com.firefly.service.query.cms.AdPosQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @author makejava
 * @since 2022-08-02 08:57:42
 */
@ConsoleApiRestController("/adpos")
public class AdPosController {
    private final AdPosQuery adPosQuery;
    private final AdPosCommand adPosCommand;

    @Autowired
    public AdPosController(AdPosQuery adPosQuery, AdPosCommand adPosCommand) {
        this.adPosQuery = adPosQuery;
        this.adPosCommand = adPosCommand;
    }

    @GetMapping("/list")
    public CommonListVo getAll(AdPosSearchDto request) {
        return adPosQuery.getList(request);
    }

    @GetMapping("/detail")
    public AdPosVo getDetail(@Validated(CommonDto.showDetail.class) CommonDto request) {
        return adPosQuery.getDetail(request.getDetailId());
    }

    @PostMapping("/create")
    public Boolean postCreate(@Validated(AdPosDto.create.class) AdPosDto request) {
        return adPosCommand.create(request);
    }

    @PostMapping("/update")
    public Boolean postUpdate(@Validated(AdPosDto.update.class) AdPosDto request) {
        return adPosCommand.update(request);
    }

    @PostMapping("/remove")
    public Boolean postRemove(@Validated(CommonDto.removeMultiple.class) CommonDto request) {
        return adPosCommand.removeByIds(request);
    }
}

